
import { Notification, Message, Loading } from 'element-ui'

import { Commit, Dispatch } from 'vuex';

import { get, defaultsDeep, cloneDeep } from 'lodash'

import { selectReportCompletion, selectReportSalaryPersonal, selectReportSalaryCompany } from '@/api/bi'



export interface State {

}

const state: State = {
    // 完工报表
    reportCompletionDateArray: [],
    // 个人工资报表
    reportSalaryPersonalDateArray: [],
    // 公司工资报表
    reportSalaryCompanyDateArray: [],
};

const getters = {};

const mutations = {

    // 绑定完工报表
    SET_COMPLETION_LIST(state: any, payload: any) {
        state.reportCompletionDateArray = payload
    },
    // 绑定个人工资报表
    SET_SALARY_PERSONAL_LIST(state: any, payload: any) {
        state.reportSalaryPersonalDateArray = payload
    },
    // 绑定公司工资报表
    SET_SALARY_COMPANY_LIST(state: any, payload: any) {
        state.reportSalaryCompanyDateArray = payload
    },




};

const actions = {

    // 08_01_完工报表
    async GET_COMPLETION(
        { state, commit, rootState, dispatch }: any,
        payload: any
    ) {
        let resp = await selectReportCompletion(payload).catch((err: any) => {
            Notification.error(err)
        })
        if (resp) {
            let responseDate = get(resp, 'data', [])
            commit('SET_COMPLETION_LIST', responseDate)
            return true
        }
    },


    // 08_04_工资报表（个人）
    async GET_SALARY_PERSONAL(
        { state, commit, rootState, dispatch }: any,
        payload: any
    ) {

        let resp = await selectReportSalaryPersonal(payload).catch((err: any) => {
            Notification.error(err)
        })
        if (resp) {
            let responseDate = get(resp, 'data', [])
            commit('SET_SALARY_PERSONAL_LIST', responseDate)
            return true
        }
    },

    // 08_05_工资报表（公司）
    async GET_SALARY_COMPANY(
        { state, commit, rootState, dispatch }: any,
        payload: any
    ) {
        let resp = await selectReportSalaryCompany(payload).catch((err: any) => {
            Notification.error(err)
        })
        if (resp) {
            let responseDate = get(resp, 'data', [])
            commit('SET_SALARY_COMPANY_LIST', responseDate)
            return true
        }
    }

}


export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
};